package cn.mill.demo;

import java.util.List;

import cn.mill.core.Mill;
import cn.mill.demo.file.Line;
import cn.mill.demo.file.LocalFileHandler;
import cn.mill.demo.open.Report;
import cn.mill.demo.open.WeatherApi;
import cn.mill.demo.postcode.Param;
import cn.mill.demo.postcode.PostCode;
import cn.mill.demo.postcode.PostCodeHandler;
import cn.mill.demo.weixin.Access;
import cn.mill.demo.weixin.WeixinHandler;

public class Demo {
	
	public static void main(String[] args) {
		Demo.demoWeixin();
		Demo.demoFile();
		Demo.weather();
		// String name = "ssssss";// "111.222.333";
		// String[] arr = name.split("\\.");
		// for (String s : arr) {
		// System.out.println("====>" + s);
		// }
		// String json =
		// "{\"total\":2,\"count\":2,\"data\":{\"openid\":[\"OPENID1\",\"OPENID2\"]},\"next_openid\":\"NEXT_OPENID\"}";
		// ;
		// JSONObject j = JSON.parseObject(json);
		// JSONObject d = j.getJSONObject("data");
		// JSONArray arr = d.getJSONArray("openid");
		// for (int i = 0; i < arr.size(); i++) {
		// System.out.println(arr.get(i));
		// }
		// System.out.println(j.get("data"));
	}
	
	/****/
	public static void weather() {
		WeatherApi weatherApi = Mill.factory(WeatherApi.class);
		Report weather = weatherApi.weather("北京");
		System.out.println(weather.toString());
	}
	
	/** 获取 微信公众号 accessToken **/
	public static void demoWeixin() {
		WeixinHandler weixinHandler = Mill.factory(WeixinHandler.class);
		Access a = weixinHandler.getAccessToken("wx07f763d98abd3806", "50385494e41785c37aeca313498ef4ed");
		System.out.println(weixinHandler.getWeiXinIp(a).toString());
	}
	
	/** 获取 省区邮政编码 **/
	public static void demoApi() {
		PostCodeHandler postCodeHandler = Mill.factory(PostCodeHandler.class);
		Param p = new Param();
		p.setProvince("河北省");
		List<PostCode> ls = postCodeHandler.getPostCode(p);
		System.out.println("==>" + ls.toString());
	}
	
	/** 从 本地 文件读取数据 **/
	public static void demoFile() {
		LocalFileHandler localFileHandler = Mill.factory(LocalFileHandler.class);
		List<Line> ls = localFileHandler.getbooks("剪切板.txt", "\\|");
		System.out.println("==>" + ls.toString());
	}
	
	public static void demoFtp() {
		
	}
}
